﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CN.DBML;

namespace CityNavigation
{
    public partial class StationView : System.Web.UI.Page
    {
        private CityNavigationDataContext dc = new CityNavigationDataContext(System.Configuration.ConfigurationManager.ConnectionStrings["CityNavigationConnectionString"].ConnectionString);

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                if (this.Page.Request.QueryString["id"] != null)
                {
                    this.lblLineName.Text = this.Page.Request.QueryString["id"].ToString();
                    this.bingGv(this.lblLineName.Text);
                }
            }
        }

        private void bingGv(string stationName)
        {
            var lines = (from item in dc.BusPassStations
                         where item.StationName == stationName
                         select new 
                         {
                             LineName = item.LineName
                         } ).Distinct().ToList();
            this.GridView1.DataSource = lines;
            this.GridView1.DataBind();
        }
    }
}